package com.jlnk.weatherdemo.model;

import com.jlnk.weatherdemo.entity.WeatherInfo;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.GET;
import retrofit2.http.Query;

public class WeatherModel {
    private static final String BASE_URL = "https://api.vvhan.com/api/";
    private static Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .build();

    public interface WeatherService {
        @GET("weather")
        Call<WeatherInfo> getWeather(@Query("city") String city);
    }

    private static WeatherService service = retrofit.create(WeatherService.class);

    public static Call<WeatherInfo> getWeatherInfo(String city) {
        return service.getWeather(city);
    }
}